from django.contrib.auth.models import User, Group
from rest_framework import serializers
from api.models import Toutiao_ShopItem, Classification_Shop


class UserSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = User
        fields = ['url', 'username', 'email', 'groups']


class GroupSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Group
        fields = ['url', 'name']


class ToutiaoItemSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Toutiao_ShopItem
        fields = ['shop_url', 'goods_id', 'shop_eid', 'goods_name', 'goods_price', 'cid', 'first_cid', 'second_cid',
                  'img', 'description', 'sell_num', 'good_count', 'mid_count', 'bad_count', 'appends_count',
                  'site_name', 'tips', 'update_time', 'create_time']


class ClassificationItemSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = Classification_Shop
        fields = ['class_id', 'class_name', 'first_cid', 'second_cid', 'update_time', 'create_time']
